﻿@using Ext.Net;
@using Ext.Net.MVC;
@using System.Configuration;
@{ var X = Html.X(); }

@X.ResourceManager().Theme((Theme)int.Parse(ConfigurationManager.AppSettings["theme"].ToString()))

@(X.Viewport()
      .Layout(LayoutType.Fit)
      .Border(false)
      .Items(
          X.Panel()
              .Layout(LayoutType.Fit)
              .Border(false)
              .BottomBar(
                  X.Toolbar()
                      .Layout(LayoutType.HBox)
                      .LayoutConfig(new HBoxLayoutConfig { Align = HBoxAlign.Middle, Pack = BoxPack.End })
                      .Items(
                          X.Button().Text("确定").Icon(Icon.Accept).OnClientClick("AddPrivilege"),
                          X.Button().Text("取消").Icon(Icon.Cancel).OnClientClick("CancelAddPrivilege")
                      )
              )
              .Items(
                  X.FormPanel()
                      .BodyStyle("background-color:transparent")
                      .Border(false)
                      .ID("AddPrivilegesForm")
                      .Padding(10)
                      .Layout(LayoutType.Table)
                      .LayoutConfig(new TableLayoutConfig { Columns = 1 })
                      .Items(
                          X.TextField().FieldLabel("用户").ID("txtPrivilegesUser").MarginSpec("10 0 0 0"),
                          X.TextField().FieldLabel("用户组").ID("txtPrivilegesGroup").MarginSpec("10 0 0 0"),
                          X.TextField().FieldLabel("功能说明(ID)").ID("txtPrivilegesFunc").MarginSpec("10 0 0 0")

                      )

              )
      ))

<script type="text/javascript">
    function AddPrivilege() {
        App.WinAddFunction.setLoading(true);

        App.direct.AddFilm(
            serializeJson("AddPrivilegesForm"),
            {
                success: function (result) {
                    if (result.Result != "OK") {
                        Ext.Msg.alert('信息', result.Message);
                    } else {
                        Ext.Msg.alert('信息', result.Message, function () {
                            parent.App.WinAddFilm.close();
                            parent.FilmSearch();
                        });
                    }
                    App.AddFilmInfo.setLoading(false);
                },
                failure: function (error) {
                    Ext.Msg.alert('信息', result.Message);
                    App.AddFilmInfo.setLoading(false);
                }
            }
        );

    }

    function CancelAddPrivilege() {
        App.txtPrivilegesUser.setValue('');
        App.txtPrivilegesGroup.setValue('');
        App.txtPrivilegesFunc.setValue('');
        parent.App.WinAddFunction.close();
        parent.FunctionSearch();
    }
</script>